<html>

<head>
    <title>会员规则</title>
</head>
<!-- 待删除界面 ，测试所用-->

<body>
    <form action="__APP__/Home/superuser/user/viprule" method="post">
        <if condition="isset($list) neq 0">
            <volist name="list" id="vo" empty="暂时没有数据">
                <div class="item">
                    <input name="rulename[]" type='text' placeholder="等级名" value="{$vo.rulename}" /> 消费区间
                    <input name="begin[]" type='text' placeholder="" value="{$vo.begin}" />
                    <input name="end[]" type='text' placeholder="等级名" value="{$vo.end}" />
                    <input name="discount[]" type='text' placeholder="优惠幅度" value="{$vo.discount}" />%
                    <button type='button' class='delete'>删除</button>
                    <br>
                    <hr>
                </div>
            </volist>
            <else/>
            <div class="item">
                <input name="rulename[]" type='text' placeholder="等级名" /> 消费区间
                <input name="begin[]" type='text' placeholder="" />
                <input name="end[]" type='text' placeholder="" />
                <input name="discount[]" type='text' placeholder="优惠幅度" />%
                <button type='button' class='delete'>删除</button>
                <br>
                <hr>
            </div>
        </if>
        <button type='button' id='add'>添加</button>
        <input type="submit" value="提交">
    </form>
    <input type="number" id="assume">
	<div id="show"></div>
    <body>
        <include file="layout/footer" />
        <script type="text/javascript">
        $('document').ready(function() {

            $('body').delegate('.delete', 'click', function() {
                var button = $(this);
                if ($('.item').size() > 1)
                    button.parent().remove();
                else {
                    $('.item input').val('');
                }
            });

            $('#add').click(function() {
                $('.item').last().after($('.item').first().prop('outerHTML'));
            });

            $('#assume').change(function() {
                $.post('__APP__/Home/superuser/user/viplevel',{
                	'assume':$('#assume').val()
                },function(data){
                	$('#show').html(data);
                });
            })
        });
        </script>